<%--
 *  File:   ConditionDetailEdit.jsp
 *  Desc:	ConditionDetailEdit
 *
 *  Date		         Author		      Changes
 *  2005-10-21	  youngwang		  Created
 *
 *  Copyright (C) 2000 - 2005 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>
<%
  //init param
  Category cat = Category.getInstance("jsp.ConditionDetailEdit");
  String strModuleName = "PCM";
  String privilegeCode = "Z0610,L205";
%>



<%
  HashMap userInfo = (HashMap)session.getAttribute("userinfo");

%>
<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>

<html>
<head>
<title></title>
<PageFlow:CheckPageFlow pageName="conditiondetailedit"/>
<%@ include file="/inc/CatchError.inc" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<%@ include file="/inc/SummaryDivision.inc" %>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<script>
function page_done()
{
  if(!checkpass(condetaileditform))
    return;
	document.condetaileditform.actionname.value = "done";
	document.condetaileditform.submit();
}

function checkpass(myform)
{
              if(isEmpty(myform.sortno.value))
              {
                      alert('<%=message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Sequence",false)) %>');
                      return false;
              }
              if(!isNumber(myform.sortno.value))
              {
                        alert('<%=message.getMessageDesc("VALUE_MUST_BE_NUMBER",label.getLabelName("L_Sequence",false)) %>');
                        return false;
             }
              if(isEmpty(myform.value.value))
             {
                          alert('<%=message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Value",false))%>');
                          return false;
             }
<%--             var str = myform.fieldnamealias.value;--%>
<%--             var arr = str.split("^");--%>
<%--             myform.fieldname.value = arr[0];--%>
             if(isEmpty(myform.fieldname.value))
             {
                        alert('<%=message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_FieldName",false)) %>');
                       return false;
            }
<%--            if(arr[1] == "date" || arr[1] == "Date")--%>
<%--           {--%>
<%--                            var dd = dateCheck(myform.value0.value,"yyyy-MM-dd","<%=JspHelper.filterNull( session.getAttribute("dateformat") )%>");--%>
<%--                            if(dd <= 0)--%>
<%--                            {--%>
<%--                                      alert('<%=message.getMessageDesc("VALUE_MUST_BE_DATE",label.getLabelName("L_Value",false)) %>');--%>
<%--                                      return;--%>
<%--                            }--%>
<%--                           else--%>
<%--                                      myform.value.value = dd;--%>
<%--          }--%>
<%--          else--%>
<%--                    myform.value.value = myform.value0.value;--%>
          return true;
}


  function page_change()
      {
               if(condetaileditform.operator.value=="is null " ||  condetaileditform.operator.value=="is not null " )

               {                      condetaileditform.value.value="";
                                     condetaileditform.value.disabled=true;
               }
                else if(condetaileditform.value.disabled==true)
               {
               condetaileditform.value.disabled=false;
               }
      }

</script>
</head>

<body>
<%
    HashMap ConditionDetailInfo=(HashMap) pageContext.getAttribute("ConditionDetailInfo");
    
  if(ConditionDetailInfo==null)
  {
      ConditionDetailInfo=new HashMap();
  }

    Vector allfieldname=(Vector)pageContext.getAttribute("fieldname");
    if (allfieldname==null)
    {
        allfieldname=new Vector();

    }

   Vector operator=(Vector)pageContext.getAttribute("operator");
    if (operator==null)
    {
        operator=new Vector();
    }

    boolean isEdit=true;
    String conditionid=request.getParameter("conditionid");
    if (conditionid==null)
  {
     conditionid ="";
     isEdit = false;
  }
 cat.debug("The ConditionDetailInfo is :"+ConditionDetailInfo);
 cat.debug("The fieldname is :"+allfieldname);
 cat.debug("The operator is : "+operator);

 HashMap hash = new HashMap();
    hash.put("text",">");
    hash.put("value",">");
    operator.add(new HashMap(hash));
    hash.put("text","<>");
    hash.put("value","<>");
    operator.add(new HashMap(hash));
    hash.put("text","<");
    hash.put("value","<");
    operator.add(new HashMap(hash));
    hash.put("text",">=");
    hash.put("value",">=");
    operator.add(new HashMap(hash));
    hash.put("text","=");
    hash.put("value","=");
    operator.add(new HashMap(hash));
    hash.put("text","<=");
    hash.put("value","<=");
    operator.add(new HashMap(hash));
    hash.put("text","like");
    hash.put("value","like");
    operator.add(new HashMap(hash));
    hash.put("text","not like");
    hash.put("value","not like");
    operator.add(new HashMap(hash));
    hash.put("text","in");
    hash.put("value","in");
    operator.add(new HashMap(hash));
     hash.put("text","not in");
    hash.put("value","not in");
    operator.add(new HashMap(hash));
     hash.put("text","is null");
    hash.put("value","is null");
    operator.add(new HashMap(hash));
    hash.put("text","is not null");
    hash.put("value","is not null");
    operator.add(new HashMap(hash));
    hash.put("text","is");
    hash.put("value","is");
    operator.add(new HashMap(hash));
    hash.put("text","is not");
    hash.put("value","is not");
    operator.add(new HashMap(hash));
    pageContext.setAttribute("operator",operator);
%>
<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2" class="summary_top"></td>
  </tr>
  <tr>
    <td colspan="2"><img src="../../images/<%= strLanguageCode %>/quote.gif" width="16" height="11">
     <%= label.getLabelName("L_EditCondition") %><%= label.getLabelName("L_Colon") %></td>
  </tr>
</table>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <form name="condetaileditform" method="post" action="../../Dispatcher" target="_parent">
			   <input type="hidden" name="pagename" value="conditiondetailedit">
			   <input type="hidden" name="actionname">
			  <input type="hidden" name="datelastupdated" value="<%=JspHelper.filterNull( new java.sql.Date(new java.util.Date().getTime()) )%>">
              <input type="hidden" name="conditionid" value="<%=JspHelper.filterNull( ConditionDetailInfo.get("conditionid") )%>">
              <input type="hidden" name="conditiondetailid" value="<%=JspHelper.filterNull( ConditionDetailInfo.get("conditiondetailid") )%>">
              <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">

  <tr>
    <td>
      <table width="100%" border="1" cellpadding="1" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <tr>
          <td class="need" width="74"><%= label.getLabelName("L_Sequence") %><%= label.getLabelName("L_Colon") %></td>
          <td>
             <%if(isEdit){%>
<%--            <input type="text" name="sortno" readonly="false" value='<%=JspHelper.filterNull(ConditionDetailInfo.get("sortno"))%>' size="15">--%>
                    <custom:text name="ConditionDetailInfo" property="sortno"  size="15"/>
           <%}else{%>
            <input type="text" name="sortno"  size="15">
            <%}%>
          </td>
        </tr>
        <tr>
          <td class="need"><%= label.getLabelName("L_FieldName") %><%= label.getLabelName("L_Colon") %></td>
          <td>

           <custom:select optionsName="fieldname" optionValueKey="columnname"  optionInnerTextKey="columndesc" property="fieldname" disabled="false" name="ConditionDetailInfo"/>


          </td>

        </tr>

        <tr>
          <td class="need"><%= label.getLabelName("L_Operator") %><%= label.getLabelName("L_Colon") %></td>
          <td>

<%--           <select name="operator" onchange="page_change()">--%>
<%--              <option value="<" selected >&lt;</option>--%>
<%--              <option value="<>">&lt;&gt;</option>--%>
<%--              <option value=">">&gt;</option>--%>
<%--              <option value=">=">&gt;=</option>--%>
<%--              <option value="=">=</option>--%>
<%--              <option value="<=">&lt;=</option>--%>
<%--              <option value="like">like</option>--%>
<%--              <option value="not like">not like</option>--%>
<%--              <option value="in ">in</option>--%>
<%--              <option value="not in ">not in</option>--%>
<%--              <option value="is null ">is null</option>--%>
<%--             <option value="is not null ">is not null</option>--%>
<%--            </select>--%>

             <custom:select optionsName="operator" optionValueKey="value"  optionInnerTextKey="text" property="operator" disabled="false" name="ConditionDetailInfo" onchange="page_change()"/>

          </td>
        </tr>
        <tr>
          <td class="need"><%= label.getLabelName("L_Value") %><%= label.getLabelName("L_Colon") %></td>
          <td>
          		<%if(!isEdit){%>
<%--            <input type="text" name="value0"  size="15">--%>
            <input type="text" name="value"  size="15">
             <%}else{%>
<%--             <input type="text" name="value" value='<%=JspHelper.filterNull(ConditionDetailInfo.get("value"))%>' size="15">	--%>
                      <custom:text name="ConditionDetailInfo" property="value" size="15"/>
              <%}%>
          </td>
        </tr>
        <tr>
          <td class="td-text"><%= label.getLabelName("L_Comment") %><%= label.getLabelName("L_Colon") %></td>
          <td>
<%--            <input type="text" name="memo" value="<%=JspHelper.filterNull(ConditionDetailInfo.get("memo"))%>" size="70">--%>
                    <custom:text name="ConditionDetailInfo" property="memo" size="70"/>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td class="summary_top"></td>
  </tr>
  <tr>
    <td class="td_center"><a onclick="page_done()"><custom:button type="1" label="L_Finish" imgsrc="finish.gif" border="0" style="width:60"/></a></td>
  </tr>
  <tr>
    <td class="summary_top"></td>
  </tr>
 </form>
</table>
</body>
</html>
